package com.trkj.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@Aspect
public class SysLogAspect {
    @Pointcut(value = "execution(* com.trkj.service..*.*(..))")
    public void cut(){}
    @Before(value = "cut()")
    public void before(JoinPoint joinPoint){
        log.debug("开始进入{}类的{}方法",joinPoint.getTarget().getClass().getName(),
                joinPoint.getSignature().getName());
    }
    @After(value = "cut()")
    public void after(JoinPoint joinPoint){
        log.debug("完成执行{}类的{}方法",joinPoint.getTarget().getClass().getName(),
                joinPoint.getSignature().getName());
    }
    @Around("cut()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        log.debug("开始环绕执行{}类的{}方法",joinPoint.getTarget().getClass().getName(),
                joinPoint.getSignature().getName());
        Object res=joinPoint.proceed();
        log.debug("环绕执行完成{}类的{}方法",joinPoint.getTarget().getClass().getName(),
                joinPoint.getSignature().getName());
        return res;
    }
}
